<template>
    <div style="padding-bottom: 50px;">
        <!-- 吸顶 -->
    <van-sticky :offset-top="0">
      <!-- 头部 -->
      <van-nav-bar title="选择日期" left-text="返回" left-arrow @click-left="onClickLeft" />
    </van-sticky>
    
    <van-calendar title="日期选择" 
    :show-title="false"
    :poppable="false" :show-confirm="false" row-height="20" :show-mark="false"
    :show-subtitle="false"
  
    :style="{ height: '240px', fontSize: '5px', paddingBottom:'15px' }" getSelectedDate 
    :value="data"
    @confirm="onConfirm"
     />
    
     <!-- 医生选择 -->
    <RegisterDoctorList />
    <!-- <van-pull-refresh v-model="refreshing" @refresh="onRefresh">
        <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多了" @load="onLoad" :style="{}">
            <van-cell v-for="item in list" :key="item" :title="item" />
        </van-list>
    </van-pull-refresh> -->
    </div>
   
</template>

<script setup lang="ts">
// import router from '@/router';
import RegisterDoctorList from "../../components/MyRegister/RegisterDoctorList.vue";
import { getDepList, getDoctorList } from "../../api/api";
import { ref, onMounted } from "vue";
import { useRoute } from "vue-router";
import  { useStore } from "vuex";


// 插件数据
const date = ref('');
const show = ref(false);
const store = useStore()
const formatDate = (date) => `${date.getFullYear()}/${date.getMonth() + 1}/${date.getDate()}`;
const onConfirm = (value) => {
    show.value = false;
    date.value = formatDate(value);
    console.log(date.value);
    store.state.confirmDate = date.value
    console.log(125,store.state.confirmDate);
};

const onClickLeft = () => history.back();

// 医生数据
const list = ref([]);
const loading = ref(false);
const finished = ref(false);
const refreshing = ref(false);
const route = useRoute()
// .calendar.toggle()
const data = ref("")


// 插件数据
const onLoad = () => {
    // 异步更新数据
    // setTimeout 仅做示例，真实场景中一般为 ajax 请求
    setTimeout(() => {
        for (let i = 0; i < 10; i++) {
            list.value.push(
                list.value.length + 1
                // 医生的列表
            );
        }

        // 加载状态结束
        loading.value = false;

        // 数据全部加载完成
        if (list.value.length >= 40) {
            finished.value = true;
        }
    }, 1000);
};
// 插件数据
const onRefresh = () => {
    // 清空列表数据
    finished.value = false;

    // 重新加载数据
    // 将 loading 设置为 true，表示处于加载状态
    loading.value = true;
    onLoad();
};

// // const list = ref([])
// onMounted(async () => {
//     const ret = await getDoctorList()
//     console.log(ret);
// })


</script>